package com.hz.zbl.controller;

import com.hz.zbl.model.request.ApiResponse;
import com.hz.zbl.service.CourseService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/course-manager")
public class CourseController {

    @Resource
    CourseService courseService;

    @PostMapping("/add-course")
    public String addCourse(@RequestParam("course_name") String course_name,
                            @RequestParam("course_code") String course_code,
                            @RequestParam("teacher_realname") String teacher_realname,
                            @RequestParam("teacher_user_id") int teacher_user_id,
                            @RequestParam("section_count") int section_count,
                            @RequestParam("course_time") String course_time,
                            @RequestParam("max_student_count") int max_student_count,
                            @RequestParam("course_profile") String course_profile,
                            @RequestParam("textbook") String textbook,
                            @RequestParam("credits_count") int credits_count,
                            @RequestParam("all_score") int all_score,
                            @RequestParam("pass_score") int pass_score,
                            @RequestParam("current_section_count") int current_section_count,
                            @RequestParam("course_year") int course_year,
                            @RequestParam("course_semester") int course_semester,
                            @RequestParam("course_room") String course_room){

        int result = courseService.addCourse(course_name, course_code, teacher_realname, teacher_user_id, section_count,
                                            course_time, max_student_count, course_profile, textbook, credits_count, all_score,
                                            pass_score, current_section_count, course_year, course_semester, course_room);



        return result > 0 ? ApiResponse.ok(result) : ApiResponse.intError();
    }
}
